<?php
// +----------------------------------------------------------------------
// | 知识星球[基于ThinkPHP5开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2018-2019 abcblockchain.io
// +----------------------------------------------------------------------
// | 后台管理使用了HisiPHP
// +----------------------------------------------------------------------
// | Author: abcblockchain.io
// +----------------------------------------------------------------------
namespace app\admin\controller;

use app\common\model\Users as UsersModel;
use app\common\model\UsersCertifications as CertificationsModel;
/**
 * 会员实名认证控制器
 * @package app\admin\controller
 */
class Certifications extends Admin
{

    /**
     * 会员列表
     * @author jyxxpy
     * @return mixed
     */
    public function index()
    {
        if ($this->request->isAjax()) {
            $map = [];
            $keyword = $this->request->param('keyword');
            $page = $this->request->param('page/d', 1);
            $limit = $this->request->param('limit/d', 20);
            if ($keyword) {
                if (is_email($keyword)) {// 邮箱
                    $map['email'] = $keyword;
                } elseif (is_mobile($keyword)) {// 手机号
                    $map['mobile'] = $keyword;
                } elseif (is_numeric($keyword)) {// ID
                    $map['id'] = $keyword;
                } else {// 用户名、昵称
                    $map['username'] = ['like', '%'.$keyword.'%'];
                }
            }
            $data['data'] = UsersModel::with('hasLevel')->where($map)->page($page)->limit($limit)->select();
            $data['count'] = UsersModel::where($map)->count('id');
            $data['code'] = 0;
            return json($data);
        }

        return $this->fetch();
    }
}
